package com.atguigu.userprofile.dao;

import com.atguigu.userprofile.bean.TaskTagRule;
import com.atguigu.userprofile.util.MySqlUtil;

import java.util.List;

public class TaskTagRuleDao {

    public static void main(String[] args) {
        List<TaskTagRule> taskTagRules = selectTaskTagRulesByTaskId("1");
        taskTagRules.forEach(System.out::println);
    }

    public static List<TaskTagRule> selectTaskTagRulesByTaskId(String taskId){
        String sql = "SELECT \n" +
                "  ttr.id , ttr.tag_id , ttr.task_id , ttr.query_value , ttr.sub_tag_id ,  ti.tag_name  AS sub_tag_value\n" +
                "FROM  \n" +
                "  task_tag_rule ttr  JOIN tag_info  ti  ON  ttr.sub_tag_id = ti.id \n" +
                "WHERE \n" +
                "  ttr.task_id = " + taskId;

        List<TaskTagRule> taskTagRules = MySqlUtil.selectList(sql, TaskTagRule.class, true);

        return taskTagRules ;
    }
}
